layui.use(['element'], function(){
    var element = layui.element;

    $(document).click(function(){
        $('.nav-list').removeClass('open')
    })
    $('.nav-menu,.nav-list').click(function(e){
        e.stopPropagation()})
    $('nav').find('.nav-menu').click(function(e){
        $('.nav-list').toggleClass('open')
    })
    adapter();

    //设置首页的当前时间
    setCurrenTime();

});

window.onresize = function (ev) {
    adapter();
}

function adapter() {

    var width = document.body.clientWidth;
    if(width < 495){
        $("#labelTitle").css("display","none");
    }else{
        $("#labelTitle").css("display","");
    }

}

//加入收藏
function addFavorite(obj) {
    var url = window.location;
    var title = document.title;

    try {
        window.external.addFavorite(url, title);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(title, url, "");
        }
        catch (e) {
            alert("抱歉，您所使用的浏览器无法完成此操作。\n\n加入收藏失败，请使用Ctrl+D进行添加");
        }
    }


}

function setCurrenTime() {
    var now = new Date();
    var myDate = now.toLocaleDateString();
    $("#date").html(myDate);
}

$(function () {
    $("#uploadProject").bind("click",function () {
        layui.use(['element','laypage', 'layer'], function(){
            var element = layui.element;
            var laypage = layui.laypage
                ,layer = layui.layer;

            layer.open({
                type: 1,
                title:"免费上线项目"
                ,offset: "auto" //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                ,id: 'layerDemo'+"auto" //防止重复弹出
                ,content: $("#frame2")
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
            });


        });

    })
})



